package com.itheima.manager.web;

import com.itheima.manager.pojo.Contact;
import com.itheima.manager.service.ISelectAllService;
import com.itheima.manager.service.imp.SelectAllServiceServiceImp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/ListServlet")
public class ListServlet extends HttpServlet {

    private ISelectAllService iSelectAll = new SelectAllServiceServiceImp();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        List<Contact> contacts = iSelectAll.selectAll();


        request.setAttribute("contacts",contacts);

        request.getRequestDispatcher("list.jsp").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request,response);
    }
}
